//    Copyright (C) Kherty.  All rights reserved.
namespace OpenLS.Spreadsheet
{
    public class NotContainsErrorsFormattingRule : StandardConditionalFormattingRule
    {
        internal override ConditionalFormattingType Type
        {
            get { return ConditionalFormattingType.NotContainsErrors; }
        }
        internal override bool Apply(Cell cell)
        {
            return ApplyStyle(cell, !(cell.Value is Error));
        }
        internal override void PrepareBeforeWrite(ConditionalFormatting conditionalFormatting, FormatType formatType)
        {
            var cell = conditionalFormatting.Range.TopLeftCell;
            this.Formula1 = string.Format("=NOT(ISERROR({0}))", cell.Label);
        }

    }
}
